import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

export default new Router({
  routes: [
    {
      path: '/',
      redirect: '/login'
    },
    {
      path: '/main',
      component: resolve => require(['../components/common/Home.vue'], resolve),
      meta: {
        requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
      },
      children: [
        {
          path: '/',
          redirect: '/product'
        },
        {
          path: '/product',
          component: resolve => require(['../components/page/product/Product.vue'], resolve),
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          }
        },
        {
          path: '/new',
          component: resolve => require(['../components/page/new/List.vue'], resolve),
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          }
        },
        {
          path: '/updateNew',
          component: resolve => require(['../components/page/new/Update.vue'], resolve),
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          }
        },
        {
          path: '/addNew',
          component: resolve => require(['../components/page/new/Add.vue'], resolve),
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          }
        },
        {
          path: '/addFile',
          component: resolve => require(['../components/page/new/AddFile.vue'], resolve),
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          }
        },
        {
          path: '/org',
          component: resolve => require(['../components/page/org/Org.vue'], resolve),
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          }
        },
        {
          path: '/user',
          component: resolve => require(['../components/page/user/User.vue'], resolve),
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          }
        },
        {
          path: '/dict',
          component: resolve => require(['../components/page/dictionaries/Dictionaries'], resolve),
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          }
        },
        {
          path: '/menu',
          component: resolve => require(['../components/page/menu/Menu'], resolve),
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          }
        },
        {
          path: '/about',
          component: resolve => require(['../components/page/about/AboutUs'], resolve),
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          }
        },
        {
          path: '/attachment',
          component: resolve => require(['../components/page/attachment/Attachment'], resolve),
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          }
        },
        {
          path: '/attachmentRelation',
          component: resolve => require(['../components/page/attachment/AttachmentManage'], resolve),
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          }
        }
      ]
    },
    {
      path: '/login',
      component: resolve => require(['../components/page/Login.vue'], resolve)
    },
  ]
})
